package com.qingmi.farmer.viewmodel;

import android.databinding.ObservableField;

import com.qingmi.farmer.data.model.GoodsInfo;
import com.qingmi.farmer.data.model.Supplier;
import com.wjjun.basemvpvm.viewmodel.BaseViewModel;

/**
 * 商品item
 * Created by 67535 on 2018/5/19.
 */
public class GoodsItemViewModel extends BaseViewModel {

    public String id;

    public Supplier supplier;

    //图标
    public final ObservableField<String> icon = new ObservableField<>();

    public final ObservableField<String> goodsName = new ObservableField<>();

    //单价
    public final ObservableField<Double> price = new ObservableField<>();

    //销量
    public final ObservableField<Integer> sellCount = new ObservableField<>();

    //供应商名字
    public final ObservableField<String> suppliersName = new ObservableField<>();

    //管局信息
    public final ObservableField<String> superviseName = new ObservableField<>();

    public GoodsItemViewModel(GoodsInfo goodsInfo) {
        id = goodsInfo.getGoodId();
        supplier = goodsInfo.getSupplier();

        icon.set(goodsInfo.getPic());
        goodsName.set(goodsInfo.getName());

        price.set(goodsInfo.getPrice());
        sellCount.set(goodsInfo.getSales());
        superviseName.set(goodsInfo.getSuperviseName());

        if (goodsInfo.getSupplier() != null) {
            suppliersName.set(goodsInfo.getSupplier().getSupplierName());
        }
    }
}
